package com.baizhi.service.impl;

import com.baizhi.dao.CmfzBannerDao;
import com.baizhi.entity.CmfzBanner;
import com.baizhi.service.CmfzBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: renpu
 * @Date: 2019/2/27 9:01
 * @Description:
 */

@Service
@Transactional
public class CmfzBannerServiceImpl implements CmfzBannerService {
    @Autowired
    private CmfzBannerDao bannerDao;


    @Override
    public Map selectByPage(int rows, int page) {
        Map map=new HashMap();

        int start=(page-1)*rows+1;
        int pagesize=rows;

        List<CmfzBanner> list=bannerDao.selectByPage(start,pagesize);
        int count=bannerDao.selectCount();
        map.put("rows",list);
        map.put("total",count);
        return map;
    }

    @Override
    public void deleteMany(int[] ids) {
        for (int id:ids) {
            bannerDao.deleteMore(id);
        }
    }

    @Override
    public void add(CmfzBanner banner) {
        bannerDao.insert(banner);
    }

    @Override
    public void update(CmfzBanner banner) {
        bannerDao.update(banner);


    }

    @Override
    public List<CmfzBanner> selectAppBanner() {
        return bannerDao.selectAppBanner();
    }

}
